package com.pb.metadata.controller;


import com.pb.infra.oth.entity.common.Page;
import com.pb.infra.oth.entity.common.Result;
import com.pb.infra.oth.util.Constant;
import com.pb.infra.oth.util.SysLog;
import com.pb.metadata.service.DimensionAttrManagementService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * 维度编号管理
 * @author weiziyu
 */

@Slf4j
@RestController
@RequestMapping("v1/alm/dimensionAttrManagement")
public class DimensionAttrManagementController {
    /**
     * 业务逻辑对象
     */
    @Resource
    private DimensionAttrManagementService dimensionAttrManagementService;

    /**
     * 日志操作表
     */
    private static final String TABLE_NAME = "param_dimm_type";

    /**
     * 日志操作功能名
     */
    private static final String OPERATION_MENU = "维度属性管理";

    /**
     * 查询分页数据
     * @param map 查询参数
     * @param page 页码
     * @return Result 返回数据
     */
    @GetMapping("select")
    @SysLog(tableName = TABLE_NAME, action = Constant.ACTION_NAME.QUERY, menuName = OPERATION_MENU)
    public Result select(@RequestParam Map<String, Object> map, Page page) {
        return dimensionAttrManagementService.select(map, page);
    }

    //新增维度属性数据
    @PostMapping("addDimAttrData")
    @SysLog(tableName = TABLE_NAME, action = Constant.ACTION_NAME.QUERY, menuName = OPERATION_MENU)
    public Result addDimAttrData(@RequestBody Map<String, Object> paramMap) {
        return dimensionAttrManagementService.addDimAttrData(paramMap);
    }

    //删除维度属性数据
    @PostMapping("delDimAttrData")
    @SysLog(tableName = TABLE_NAME, action = Constant.ACTION_NAME.QUERY, menuName = OPERATION_MENU)
    public Result delDimAttrData(@RequestBody List<Map<String,Object>> dimNoList) {
        return dimensionAttrManagementService.delDimAttrData(dimNoList);
    }

    //修改维度属性数据
    @PostMapping("updateDimAttrData")
    @SysLog(tableName = TABLE_NAME, action = Constant.ACTION_NAME.QUERY, menuName = OPERATION_MENU)
    public Result updateDimAttrData(@RequestBody Map<String, Object> paramMap) {
        return dimensionAttrManagementService.updateDimAttrData(paramMap);
    }

    //查询维度属性注册数据
    @PostMapping("getDimAttrRegDataByDimNo")
    @SysLog(tableName = TABLE_NAME, action = Constant.ACTION_NAME.QUERY, menuName = OPERATION_MENU)
    public Result getDimAttrRegDataByDimNo(@RequestBody Map<String, Object> paramMap) {
        return dimensionAttrManagementService.getDimAttrRegDataByDimNo(paramMap);
    }

    //增加维度属性注册数据
    @PostMapping("addDimAttrRegData")
    @SysLog(tableName = TABLE_NAME, action = Constant.ACTION_NAME.QUERY, menuName = OPERATION_MENU)
    public Result addDimAttrRegData(@RequestBody Map<String, Object> paramMap) {
        return dimensionAttrManagementService.addDimAttrRegData(paramMap);
    }

    //校验属性编码是否唯一
    @PostMapping("validUnique")
    @SysLog(tableName = TABLE_NAME, action = Constant.ACTION_NAME.QUERY, menuName = OPERATION_MENU)
    public Result validUnique(@RequestBody Map<String, Object> paramMap) {
        return dimensionAttrManagementService.validUnique(paramMap);
    }

    //修改维度属性注册数据
    @PostMapping("updateDimAttrRegData")
    @SysLog(tableName = TABLE_NAME, action = Constant.ACTION_NAME.QUERY, menuName = OPERATION_MENU)
    public Result updateDimAttrRegData(@RequestBody Map<String, Object> paramMap) {
        return dimensionAttrManagementService.updateDimAttrRegData(paramMap);
    }

    //删除维度属性注册数据
    @PostMapping("delAttrRegData")
    @SysLog(tableName = TABLE_NAME, action = Constant.ACTION_NAME.QUERY, menuName = OPERATION_MENU)
    public Result delAttrRegData(@RequestBody List<Map<String,Object>> AttrRegList) {
        return dimensionAttrManagementService.delAttrRegData(AttrRegList);
    }


}
